//
//  GifModel.m
//  Mango
//
//  Created by lanou3g on 16/5/7.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "GifModel.h"

@implementation GifModel
- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"gif"]) {
        NSDictionary *gifDict = value[0];
        [self setValuesForKeysWithDictionary:gifDict];
    }
}


- (CGFloat)cellHeight {
    CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width - 16, MAXFLOAT);
    NSDictionary *dict = @{NSFontAttributeName : [UIFont systemFontOfSize:17]};
    CGFloat height = [self.title boundingRectWithSize:size options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dict context:nil].size.height;
    
    CGFloat imageHeight = [UIScreen mainScreen].bounds.size.width * self.height / self.width;
    
    CGFloat cellHeight = 8 + height + 8 + imageHeight + 15 + 30 + 8;
    
    _imageFrame = CGRectMake(0, 16 + height, [UIScreen mainScreen].bounds.size.width, imageHeight);
    
    return cellHeight;
}
@end
